package com.example.demo.service;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.example.demo.domain.Category;
import com.example.demo.mapper.CategoryMapper;

@Service
public class CategoryServiceImpl implements CategoryService{
	private final Logger logger = LoggerFactory.getLogger(this.getClass());

	@Autowired
	CategoryMapper categoryMapper;
	@Override
	public String getCategoryNameByCgid(Short cgid) {
		logger.info("----getCategoryNameByCgid: ");
		logger.info(cgid.toString());
		Category cg =  categoryMapper.selectCategoryByID(cgid);
		if(cg!=null) {
			logger.info(cg.toString());
			return cg.getCgname();
		}
		else {
			return "";
		}
	}
	@Override
	public List<Category> getCategories() {
		return categoryMapper.selectCategories();
	}

}
